#include "enplisten.h"
#include "enpctrl.h"

int CEnpListen::Init(CEnpCtrl& stOwner, const CEnpListenInfo& stListenInfo)
{
    int iRet = 0;

    m_pstOwner = &stOwner;

    m_stListenInfo = stListenInfo;
    iRet = m_stSocket.Listen(m_stListenInfo.m_szListenIP(), m_stListenInfo.m_unListenPort);
    CHECK_RETURN(iRet);

    iRet = Register(stOwner,
        &CEnpCtrl::OnListenEvent,
        stOwner.m_stEpoll,
        m_stSocket.GetSocket(),
        EPOLLIN);
    CHECK_RETURN(iRet);

    return 0;
}
